package cn.cheln.explorer.beans;

import android.os.StatFs;
import cn.cheln.explorer.util.ReadSystemMemory;
import java.io.File;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;

public class FileUtil
{
  private static final int COPY_BUFFER_SIZE = 32768;
  static final String TAG = "FileUtils";

  public static String addParentheses(String paramString)
  {
    return " ( " + paramString + " ) ";
  }

  public static String formatSize(float paramFloat)
  {
    float f;
    long l1 = 1024L * 1024L;
    long l2 = l1 * 1024L;
    if (paramFloat < (float)1024L)
      f = paramFloat;
    for (String str1 = " B"; ; str1 = " G")
    {
      while (true)
      {
        String str2 = new BigDecimal(f).setScale(2, RoundingMode.CEILING).toString();
        if (str2.endsWith("0"))
          str2 = str2.substring(0, -1 + str2.length());
        if (str2.endsWith("0"))
          str2 = str2.substring(0, -1 + str2.length());
        if (str2.endsWith("."))
          str2 = str2.substring(0, -1 + str2.length());
        return str2 + str1;
        if (paramFloat < (float)l1)
        {
          f = paramFloat / (float)1024L;
          str1 = " K";
        }
        if (paramFloat >= (float)l2)
          break;
        f = paramFloat / (float)l1;
        str1 = " M";
      }
      f = paramFloat / (float)l2;
    }
  }

  public static String formatSize4GB(float paramFloat)
  {
    long l = 1024L * 1024L * 1024L;
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = Float.valueOf(paramFloat / (float)l);
    return String.format("%.2f GB", arrayOfObject);
  }

  public static HashMap<String, Object> getAvailableStore(String paramString)
  {
    HashMap localHashMap = new HashMap();
    StatFs localStatFs = new StatFs(paramString);
    long l1 = localStatFs.getBlockSize();
    long l2 = localStatFs.getBlockCount();
    long l3 = localStatFs.getFreeBlocks();
    String str1 = formatSize((float)(l2 * l1));
    String str2 = formatSize((float)(l3 * l1));
    String str3 = formatSize((float)(l2 * l1));
    String str4 = formatSize((float)(l3 * l1));
    localHashMap.put("totalSize", Long.valueOf(l2 * l1));
    localHashMap.put("availaSize", Long.valueOf(l3 * l1));
    localHashMap.put("usedSize", Long.valueOf(l1 * (l2 - l3)));
    localHashMap.put("totalBlocks", str1);
    localHashMap.put("availaBlocks", str2);
    localHashMap.put("memTotalBlocks", ReadSystemMemory.getTotalInternalMemorySize());
    localHashMap.put("memAvailaBlocks", ReadSystemMemory.getAvailableInternalMemorySize());
    localHashMap.put("availaSizeStr", str4);
    localHashMap.put("totalSizeStr", str3);
    return localHashMap;
  }

  public static File getFile(File paramFile, String paramString)
  {
    String str1 = paramFile.getAbsolutePath();
    String str2 = "/";
    if (str1.endsWith("/"))
      str2 = "";
    return new File(str1 + str2 + paramString);
  }

  public static long getFileSize(File paramFile)
    throws Exception
  {
    long l = 0L;
    File[] arrayOfFile = paramFile.listFiles();
    if (arrayOfFile == null)
      return paramFile.length();
    int i = 0;
    if (i >= arrayOfFile.length)
      label19: return l;
    if (arrayOfFile[i].isDirectory())
      l += getFileSize(arrayOfFile[i]);
    while (true)
    {
      ++i;
      break label19:
      l += arrayOfFile[i].length();
    }
  }

  public static String getName(String paramString)
  {
    return paramString.substring(1 + paramString.lastIndexOf("/"));
  }

  public static String getNameTitle(String paramString)
  {
    String str = getName(paramString);
    int i = str.lastIndexOf(".");
    if (i == -1)
      return str;
    return str.substring(0, i);
  }

  public static String getParent(File paramFile)
  {
    return getParent(paramFile.getAbsolutePath());
  }

  public static String getParent(String paramString)
  {
    String str1 = paramString.substring(1 + paramString.lastIndexOf("/"));
    String str2 = paramString.substring(0, paramString.length() - str1.length());
    if (str2.endsWith("/"))
      str2 = str2.substring(0, -1 + str2.length());
    return str2;
  }

  public static File getPathWithoutFilename(File paramFile)
  {
    if (paramFile != null)
    {
      if (paramFile.isDirectory())
        return paramFile;
      return new File(getParent(paramFile));
    }
    return null;
  }

  public static String getRealExtension(String paramString)
  {
    if (paramString == null)
      return null;
    int i = paramString.lastIndexOf(".");
    if (i >= 0)
      return paramString.substring(i + 1).trim();
    return "";
  }

  public static String getRealLowerCaseExtension(String paramString)
  {
    String str = getRealExtension(paramString);
    if (str.equals(""))
      return "";
    return str.toLowerCase();
  }

  public static String parseMimePrefix(String paramString)
  {
    int i = paramString.lastIndexOf("/");
    if (i == -1)
      throw new IllegalStateException("cannt find seperator");
    return paramString.substring(0, i);
  }

  public static File reaplcePath(File paramFile1, File paramFile2)
  {
    return new File(paramFile2.getAbsolutePath() + "/" + paramFile1.getName());
  }

  public static String removeExt(String paramString)
  {
    int i = paramString.lastIndexOf(".");
    if (i <= 0)
      return paramString;
    return paramString.substring(0, i);
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     cn.cheln.explorer.beans.FileUtil
 * JD-Core Version:    0.5.2
 */